home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / BOLEUI.PAK / OLESTD.H < prev   
C/C++ Source or Header  |  1997-05-06  |  30KB  |  862 lines

  1. /*************************************************************************
  2. **
  3. **    OLE 2.0 Standard Utilities
  4. **
  5. **    olestd.h
  6. **
  7. **    This file contains file contains data structure defintions,
  8. **    function prototypes, constants, etc. for the common OLE 2.0
  9. **    utilities.
  10. **    These utilities include the following:
  11. **          Debuging Assert/Verify macros
  12. **          HIMETRIC conversion routines
  13. **          reference counting debug support
  14. **          OleStd API's for common compound-document app support
  15. **
  16. *************************************************************************/
  17. /*
  18.  *      C/C++ Run Time Library - Version 6.5
  19.  *
  20.  *      Copyright (c) 1994 by Borland International
  21.  *      All Rights Reserved.
  22.  *
  23.  */
  24.  
  25. #if !defined( _OLESTD_H_ )
  26. #define _OLESTD_H_
  27.  
  28. // String table defines...
  29. #define  IDS_OLESTDNOCREATEFILE   700
  30. #define  IDS_OLESTDNOOPENFILE     701
  31. #define  IDS_OLESTDDISKFULL       702
  32.  
  33.  
  34. #ifndef RC_INVOKED
  35.  
  36. //#pragma message ("INCLUDING OLESTD.H from " __FILE__)
  37.  
  38. #if defined( __TURBOC__ ) || defined( WIN32 )
  39. #define _based(a)
  40. #endif
  41.  
  42. #include <dos.h>        // needed for filetime
  43. #include <commdlg.h>    // needed for LPPRINTDLG
  44. #include <shellapi.h>   // needed for HKEY
  45.  
  46. /*
  47.  * Some C interface declaration stuff
  48.  */
  49.  
  50. #if ! defined(__cplusplus)
  51. typedef struct tagINTERFACEIMPL {
  52.         IUnknownVtbl FAR*       lpVtbl;
  53.         LPVOID                  lpBack;
  54.         int                     cRef;   // interface specific ref count.
  55. } INTERFACEIMPL, FAR* LPINTERFACEIMPL;
  56.  
  57. #define INIT_INTERFACEIMPL(lpIFace, pVtbl, pBack)   \
  58.         ((lpIFace)->lpVtbl = pVtbl, \
  59.             ((LPINTERFACEIMPL)(lpIFace))->lpBack = (LPVOID)pBack,   \
  60.             ((LPINTERFACEIMPL)(lpIFace))->cRef = 0  \
  61.         )
  62.  
  63. #if defined( _DEBUG )
  64. #define OleDbgQueryInterfaceMethod(lpUnk)   \
  65.         ((lpUnk) != NULL ? ((LPINTERFACEIMPL)(lpUnk))->cRef++ : 0)
  66. #define OleDbgAddRefMethod(lpThis, iface)   \
  67.         ((LPINTERFACEIMPL)(lpThis))->cRef++
  68.  
  69. #if _DEBUGLEVEL >= 2
  70. #define OleDbgReleaseMethod(lpThis, iface) \
  71.         (--((LPINTERFACEIMPL)(lpThis))->cRef == 0 ? \
  72.             OleDbgOut("\t" iface "* RELEASED (cRef == 0)\r\n"),1 : \
  73.              (((LPINTERFACEIMPL)(lpThis))->cRef < 0) ? \
  74.                 ( \
  75.                     DebugBreak(), \
  76.                     OleDbgOut(  \
  77.                         "\tERROR: " iface "* RELEASED TOO MANY TIMES\r\n") \
  78.                 ),1 : \
  79.                 1)
  80.  
  81. #else       // if _DEBUGLEVEL < 2
  82. #define OleDbgReleaseMethod(lpThis, iface) \
  83.         (--((LPINTERFACEIMPL)(lpThis))->cRef == 0 ? \
  84.             1 : \
  85.              (((LPINTERFACEIMPL)(lpThis))->cRef < 0) ? \
  86.                 ( \
  87.                     OleDbgOut(  \
  88.                         "\tERROR: " iface "* RELEASED TOO MANY TIMES\r\n") \
  89.         ),1 : \
  90.                 1)
  91.  
  92. #endif      // if _DEBUGLEVEL < 2
  93.  
  94. #else       // ! defined (_DEBUG)
  95.  
  96. #define OleDbgQueryInterfaceMethod(lpUnk)
  97. #define OleDbgAddRefMethod(lpThis, iface)
  98. #define OleDbgReleaseMethod(lpThis, iface)
  99.  
  100. #endif      // if defined( _DEBUG )
  101.  
  102. #endif      // ! defined(__cplusplus)
  103.  
  104. /*
  105.  * Some docfiles stuff
  106.  */
  107.  
  108. #define STGM_DFRALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_DENY_WRITE)
  109. #define STGM_DFALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE)
  110. #define STGM_SALL (STGM_READWRITE | STGM_SHARE_EXCLUSIVE)
  111.  
  112. /*
  113.  * Some moniker stuff
  114.  */
  115.  
  116. // Delimeter used to separate ItemMoniker pieces of a composite moniker
  117. #if defined( _MAC )
  118. #define OLESTDDELIM ":"
  119. #else
  120. #define OLESTDDELIM "\\"
  121. #endif
  122.  
  123. /*
  124.  * Some Concurrency stuff
  125.  */
  126.  
  127. /* standard Delay (in msec) to wait before retrying an LRPC call.
  128. **    this value is returned from IMessageFilter::RetryRejectedCall
  129. */
  130. #define OLESTDRETRYDELAY    (DWORD)5000
  131.  
  132. /* Cancel the pending outgoing LRPC call.
  133. **    this value is returned from IMessageFilter::RetryRejectedCall
  134. */
  135. #define OLESTDCANCELRETRY   (DWORD)-1
  136.  
  137. /*
  138.  * Some Icon support stuff.
  139.  *
  140.  * The following API's are now OBSOLETE because equivalent API's have been
  141.  * added to the OLE2.DLL library
  142.  *      GetIconOfFile       superceeded by OleGetIconOfFile
  143.  *      GetIconOfClass      superceeded by OleGetIconOfClass
  144.  *      OleUIMetafilePictFromIconAndLabel
  145.  *                          superceeded by OleMetafilePictFromIconAndLabel
  146.  *
  147.  * The following macros are defined for backward compatibility with previous
  148.  * versions of the OLE2UI library. It is recommended that the new Ole* API's
  149.  * should be used instead.
  150.  */
  151. #define GetIconOfFile(hInst, lpszFileName, fUseFileAsLabel) \
  152.     OleGetIconOfFile(lpszFileName, fUseFileAsLabel)
  153.  
  154. #define GetIconOfClass(hInst, rclsid, lpszLabel, fUseTypeAsLabel) \
  155.     OleGetIconOfClass(rclsid, lpszLabel, fUseTypeAsLabel)
  156.  
  157. #define OleUIMetafilePictFromIconAndLabel(hIcon,pszLabel,pszSourceFile,iIcon)\
  158.     OleMetafilePictFromIconAndLabel(hIcon, pszLabel, pszSourceFile, iIcon)
  159.  
  160.  
  161. /*
  162.  * Some Clipboard Copy/Paste & Drag/Drop support stuff
  163.  */
  164.  
  165. //Macro to set all FormatEtc fields
  166. #define SETFORMATETC(fe, cf, asp, td, med, li)   \
  167.     ((fe).cfFormat=cf, \
  168.      (fe).dwAspect=asp, \
  169.      (fe).ptd=td, \
  170.      (fe).tymed=med, \
  171.      (fe).lindex=li)
  172.  
  173. //Macro to set interesting FormatEtc fields defaulting the others.
  174. #define SETDEFAULTFORMATETC(fe, cf, med)  \
  175.     ((fe).cfFormat=cf, \
  176.      (fe).dwAspect=DVASPECT_CONTENT, \
  177.      (fe).ptd=NULL, \
  178.      (fe).tymed=med, \
  179.      (fe).lindex=-1)
  180.  
  181. // Macro to test if two FormatEtc structures are an exact match
  182. #define IsEqualFORMATETC(fe1, fe2)  \
  183.     (OleStdCompareFormatEtc(&(fe1), &(fe2))==0)
  184.  
  185. // Clipboard format strings
  186. #define CF_EMBEDSOURCE      "Embed Source"
  187. #define CF_EMBEDDEDOBJECT   "Embedded Object"
  188. #define CF_LINKSOURCE       "Link Source"
  189. #define CF_CUSTOMLINKSOURCE "Custom Link Source"
  190. #define CF_OBJECTDESCRIPTOR "Object Descriptor"
  191. #define CF_LINKSRCDESCRIPTOR "Link Source Descriptor"
  192. #define CF_OWNERLINK        "OwnerLink"
  193. #define CF_FILENAME         "FileName"
  194.  
  195. #define OleStdQueryOleObjectData(lpformatetc)   \
  196.     (((lpformatetc)->tymed & TYMED_ISTORAGE) ?    \
  197.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  198.  
  199. #define OleStdQueryLinkSourceData(lpformatetc)   \
  200.     (((lpformatetc)->tymed & TYMED_ISTREAM) ?    \
  201.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  202.  
  203. #define OleStdQueryObjectDescriptorData(lpformatetc)    \
  204.     (((lpformatetc)->tymed & TYMED_HGLOBAL) ?    \
  205.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  206.  
  207. #define OleStdQueryFormatMedium(lpformatetc, tymd)  \
  208.     (((lpformatetc)->tymed & tymd) ?    \
  209.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  210.  
  211. // Make an independent copy of a MetafilePict
  212. #define OleStdCopyMetafilePict(hpictin, phpictout)  \
  213.     (*(phpictout) = OleDuplicateData(hpictin,CF_METAFILEPICT,GHND|GMEM_SHARE))
  214.  
  215.  
  216. // REVIEW: these need to be added to OLE2.H
  217. #if !defined( DD_DEFSCROLLINTERVAL )
  218. #define DD_DEFSCROLLINTERVAL    50
  219. #endif
  220.  
  221. #if !defined( DD_DEFDRAGDELAY )
  222. #define DD_DEFDRAGDELAY         200
  223. #endif
  224.  
  225. #if !defined( DD_DEFDRAGMINDIST )
  226. #define DD_DEFDRAGMINDIST       2
  227. #endif
  228.  
  229.  
  230. /* OleStdGetDropEffect
  231. ** -------------------
  232. **
  233. ** Convert a keyboard state into a DROPEFFECT.
  234. **
  235. ** returns the DROPEFFECT value derived from the key state.
  236. **    the following is the standard interpretation:
  237. **          no modifier -- Default Drop     (NULL is returned)
  238. **          CTRL        -- DROPEFFECT_COPY
  239. **          SHIFT       -- DROPEFFECT_MOVE
  240. **          CTRL-SHIFT  -- DROPEFFECT_LINK
  241. **
  242. **    Default Drop: this depends on the type of the target application.
  243. **    this is re-interpretable by each target application. a typical
  244. **    interpretation is if the drag is local to the same document
  245. **    (which is source of the drag) then a MOVE operation is
  246. **    performed. if the drag is not local, then a COPY operation is
  247. **    performed.
  248. */
  249. #define OleStdGetDropEffect(grfKeyState)    \
  250.     ( (grfKeyState & MK_CONTROL) ?          \
  251.         ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_LINK : DROPEFFECT_COPY ) :  \
  252.         ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_MOVE : 0 ) )
  253.  
  254.  
  255. /* The OLEUIPASTEFLAG enumeration is used by the OLEUIPASTEENTRY structure.
  256.  *
  257.  * OLEUIPASTE_ENABLEICON    If the container does not specify this flag for the entry in the
  258.  *   OLEUIPASTEENTRY array passed as input to OleUIPasteSpecial, the DisplayAsIcon button will be
  259.  *   unchecked and disabled when the the user selects the format that corresponds to the entry.
  260.  *
  261.  * OLEUIPASTE_PASTEONLY     Indicates that the entry in the OLEUIPASTEENTRY array is valid for pasting only.
  262.  * OLEUIPASTE_PASTE         Indicates that the entry in the OLEUIPASTEENTRY array is valid for pasting. It
  263.  *   may also be valid for linking if any of the following linking flags are specified.
  264.  *
  265.  * If the entry in the OLEUIPASTEENTRY array is valid for linking, the following flags indicate which link
  266.  * types are acceptable by OR'ing together the appropriate OLEUIPASTE_LINKTYPE<#> values.
  267.  * These values correspond as follows to the array of link types passed to OleUIPasteSpecial:
  268.  *   OLEUIPASTE_LINKTYPE1=arrLinkTypes[0]
  269.  *   OLEUIPASTE_LINKTYPE2=arrLinkTypes[1]
  270.  *   OLEUIPASTE_LINKTYPE3=arrLinkTypes[2]
  271.  *   OLEUIPASTE_LINKTYPE4=arrLinkTypes[3]
  272.  *   OLEUIPASTE_LINKTYPE5=arrLinkTypes[4]
  273.  *   OLEUIPASTE_LINKTYPE6=arrLinkTypes[5]
  274.  *   OLEUIPASTE_LINKTYPE7=arrLinkTypes[6]
  275.  *  OLEUIPASTE_LINKTYPE8=arrLinkTypes[7]
  276.  *
  277.  * where,
  278.  *   UINT arrLinkTypes[8] is an array of registered clipboard formats for linking. A maximium of 8 link
  279.  *   types are allowed.
  280.  */
  281.  
  282. typedef enum tagOLEUIPASTEFLAG
  283. {
  284.    OLEUIPASTE_ENABLEICON    = 2048,     // enable display as icon
  285.    OLEUIPASTE_PASTEONLY     = 0,
  286.    OLEUIPASTE_PASTE         = 512,
  287.    OLEUIPASTE_LINKANYTYPE   = 1024,
  288.    OLEUIPASTE_LINKTYPE1     = 1,
  289.    OLEUIPASTE_LINKTYPE2     = 2,
  290.    OLEUIPASTE_LINKTYPE3     = 4,
  291.    OLEUIPASTE_LINKTYPE4     = 8,
  292.    OLEUIPASTE_LINKTYPE5     = 16,
  293.    OLEUIPASTE_LINKTYPE6     = 32,
  294.    OLEUIPASTE_LINKTYPE7     = 64,
  295.    OLEUIPASTE_LINKTYPE8     = 128
  296. } OLEUIPASTEFLAG;
  297.  
  298. /*
  299.  * PasteEntry structure
  300.  * --------------------
  301.  * An array of OLEUIPASTEENTRY entries is specified for the PasteSpecial dialog
  302.  * box. Each entry includes a FORMATETC which specifies the formats that are
  303.  * acceptable, a string that is to represent the format in the  dialog's list
  304.  * box, a string to customize the result text of the dialog and a set of flags
  305.  * from the OLEUIPASTEFLAG enumeration.  The flags indicate if the entry is
  306.  * valid for pasting only, linking only or both pasting and linking. If the
  307.  * entry is valid for linking, the flags indicate which link types are
  308.  * acceptable by OR'ing together the appropriate OLEUIPASTE_LINKTYPE<#> values.
  309.  * These values correspond to the array of link types as follows:
  310.  *   OLEUIPASTE_LINKTYPE1=arrLinkTypes[0]
  311.  *   OLEUIPASTE_LINKTYPE2=arrLinkTypes[1]
  312.  *   OLEUIPASTE_LINKTYPE3=arrLinkTypes[2]
  313.  *   OLEUIPASTE_LINKTYPE4=arrLinkTypes[3]
  314.  *   OLEUIPASTE_LINKTYPE5=arrLinkTypes[4]
  315.  *   OLEUIPASTE_LINKTYPE6=arrLinkTypes[5]
  316.  *   OLEUIPASTE_LINKTYPE7=arrLinkTypes[6]
  317.  *   OLEUIPASTE_LINKTYPE8=arrLinkTypes[7]
  318.  *   UINT arrLinkTypes[8]; is an array of registered clipboard formats
  319.  *                        for linking. A maximium of 8 link types are allowed.
  320.  */
  321.  
  322. typedef struct tagOLEUIPASTEENTRY
  323. {
  324.    FORMATETC        fmtetc;            // Format that is acceptable. The paste
  325.                                        //   dialog checks if this format is
  326.                                        //   offered by the object on the
  327.                                        //   clipboard and if so offers it for
  328.                                        //   selection to the user.
  329.    LPCSTR           lpstrFormatName;   // String that represents the format to the user. Any %s
  330.                                        //   in this string is replaced by the FullUserTypeName
  331.                                        //   of the object on the clipboard and the resulting string
  332.                                        //   is placed in the list box of the dialog. Atmost
  333.                                        //   one %s is allowed. The presence or absence of %s indicates
  334.                                        //   if the result text is to indicate that data is
  335.                                        //   being pasted or that an object that can be activated by
  336.                                        //   an application is being pasted. If %s is
  337.                                        //   present, the result-text says that an object is being pasted.
  338.                                        //   Otherwise it says that data is being pasted.
  339.    LPCSTR           lpstrResultText;   // String to customize the result text of the dialog when
  340.                                        //  the user selects the format correspoding to this
  341.                                        //  entry. Any %s in this string is replaced by the the application
  342.                                        //  name or FullUserTypeName of the object on
  343.                                        //  the clipboard. Atmost one %s is allowed.
  344.    DWORD            dwFlags;           // Values from OLEUIPASTEFLAG enum
  345.    DWORD            dwScratchSpace;    // Scratch space available to be used
  346.                                        //   by routines which loop through an
  347.                                        //   IEnumFORMATETC* to mark if the
  348.                                        //   PasteEntry format is available.
  349.                                        //   this field CAN be left uninitialized.
  350. } OLEUIPASTEENTRY, *POLEUIPASTEENTRY, FAR *LPOLEUIPASTEENTRY;
  351.  
  352. #define OLESTDDROP_NONE         0
  353. #define OLESTDDROP_DEFAULT      1
  354. #define OLESTDDROP_NONDEFAULT   2
  355.  
  356.  
  357. /*
  358.  * Some misc stuff
  359.  */
  360.  
  361. #define EMBEDDINGFLAG "Embedding"     // Cmd line switch for launching a srvr
  362.  
  363. #define HIMETRIC_PER_INCH   2540      // number HIMETRIC units per inch
  364. #define PTS_PER_INCH        72        // number points (font size) per inch
  365.  
  366. #if 0
  367.     #if 0
  368.     #define MAP_PIX_TO_LOGHIM(x,ppli)   MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
  369.     #define MAP_LOGHIM_TO_PIX(x,ppli)   MulDiv((ppli), (x), HIMETRIC_PER_INCH)
  370.     #else
  371.  
  372.     #define MAP_PIX_TO_LOGHIM(pixel, pixelsPerInch) \
  373.         ((ULONG) ((((ULONG)HIMETRIC_PER_INCH) * pixel) / pixelsPerInch))
  374.  
  375.     #define MAP_LOGHIM_TO_PIX(hiMetric, pixelsPerInch) \
  376.         (UINT) ((((double) hiMetric) * pixelsPerInch) / HIMETRIC_PER_INCH)
  377.  
  378.     #endif
  379. #else
  380.     #define MAP_PIX_TO_LOGHIM(pixel, pixelsPerInch) \
  381.         ((ULONG) ((((ULONG)HIMETRIC_PER_INCH) * pixel + (pixelsPerInch >> 1)) / pixelsPerInch))
  382.     #define MAP_LOGHIM_TO_PIX(hiMetric, pixelsPerInch) \
  383.      (UINT) ((((double) hiMetric) * pixelsPerInch + (HIMETRIC_PER_INCH >> 1)) / HIMETRIC_PER_INCH)
  384. #endif
  385.  
  386. // Returns TRUE if all fields of the two Rect's are equal, else FALSE.
  387. #define AreRectsEqual(lprc1, lprc2)     \
  388.     (((lprc1->top == lprc2->top) &&     \
  389.       (lprc1->left == lprc2->left) &&   \
  390.       (lprc1->right == lprc2->right) && \
  391.       (lprc1->bottom == lprc2->bottom)) ? TRUE : FALSE)
  392.  
  393. #define LSTRCPYN(lpdst, lpsrc, cch) \
  394. (\
  395.     (lpdst)[(cch)-1] = '\0', \
  396.     (cch>1 ? lstrcpyn(lpdst, lpsrc, (cch)-1) : 0)\
  397. )
  398.  
  399.  
  400. /****** DEBUG Stuff *****************************************************/
  401.  
  402. #ifdef _DEBUG
  403.  
  404. #if !defined( _DBGTRACE )
  405. #define _DEBUGLEVEL 2
  406. #else
  407. #define _DEBUGLEVEL _DBGTRACE
  408. #endif
  409.  
  410.  
  411. #if defined( NOASSERT )
  412.  
  413. #define OLEDBGASSERTDATA
  414. #define OleDbgAssert(a)
  415. #define OleDbgAssertSz(a, b)
  416. #define OleDbgVerify(a)
  417. #define OleDbgVerifySz(a, b)
  418.  
  419. #else   // ! NOASSERT
  420.  
  421. #define OLEDBGASSERTDATA    \
  422.         static char _based(_segname("_CODE")) _szAssertFile[]= __FILE__;
  423.  
  424. #define OleDbgAssert(a) \
  425.         (!(a) ? FnAssert(#a, NULL, _szAssertFile, __LINE__) : (HRESULT)1)
  426.  
  427. #define OleDbgAssertSz(a, b)    \
  428.         (!(a) ? FnAssert(#a, b, _szAssertFile, __LINE__) : (HRESULT)1)
  429.  
  430. #define OleDbgVerify(a) \
  431.         OleDbgAssert(a)
  432.  
  433. #define OleDbgVerifySz(a, b)    \
  434.         OleDbgAssertSz(a, b)
  435.  
  436. #endif  // ! NOASSERT
  437.  
  438.  
  439. #define OLEDBGDATA_MAIN(szPrefix)   \
  440.         char near g_szDbgPrefix[] = szPrefix;    \
  441.         OLEDBGASSERTDATA
  442. #define OLEDBGDATA  \
  443.         extern char near g_szDbgPrefix[];    \
  444.         OLEDBGASSERTDATA
  445.  
  446. #define OLEDBG_BEGIN(lpsz) \
  447.         OleDbgPrintAlways(g_szDbgPrefix,lpsz,1);
  448.  
  449. #define OLEDBG_END  \
  450.         OleDbgPrintAlways(g_szDbgPrefix,"End\r\n",-1);
  451.  
  452. #define OleDbgOut(lpsz) \
  453.         OleDbgPrintAlways(g_szDbgPrefix,lpsz,0)
  454.  
  455. #define OleDbgOutNoPrefix(lpsz) \
  456.         OleDbgPrintAlways("",lpsz,0)
  457.  
  458. #define OleDbgOutRefCnt(lpsz,lpObj,refcnt)      \
  459.         OleDbgPrintRefCntAlways(g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  460.  
  461. #define OleDbgOutRect(lpsz,lpRect)      \
  462.         OleDbgPrintRectAlways(g_szDbgPrefix,lpsz,lpRect)
  463.  
  464. #define OleDbgOutHResult(lpsz,hr)   \
  465.         OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,GetScode(hr))
  466.  
  467. #define OleDbgOutScode(lpsz,sc) \
  468.         OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,sc)
  469.  
  470. #define OleDbgOut1(lpsz)    \
  471.         OleDbgPrint(1,g_szDbgPrefix,lpsz,0)
  472.  
  473. #define OleDbgOutNoPrefix1(lpsz)    \
  474.         OleDbgPrint(1,"",lpsz,0)
  475.  
  476. #define OLEDBG_BEGIN1(lpsz)    \
  477.         OleDbgPrint(1,g_szDbgPrefix,lpsz,1);
  478.  
  479. #define OLEDBG_END1 \
  480.         OleDbgPrint(1,g_szDbgPrefix,"End\r\n",-1);
  481.  
  482. #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt)     \
  483.         OleDbgPrintRefCnt(1,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  484.  
  485. #define OleDbgOutRect1(lpsz,lpRect)     \
  486.         OleDbgPrintRect(1,g_szDbgPrefix,lpsz,lpRect)
  487.  
  488. #define OleDbgOut2(lpsz)    \
  489.         OleDbgPrint(2,g_szDbgPrefix,lpsz,0)
  490.  
  491. #define OleDbgOutNoPrefix2(lpsz)    \
  492.         OleDbgPrint(2,"",lpsz,0)
  493.  
  494. #define OLEDBG_BEGIN2(lpsz)    \
  495.         OleDbgPrint(2,g_szDbgPrefix,lpsz,1);
  496.  
  497. #define OLEDBG_END2 \
  498.         OleDbgPrint(2,g_szDbgPrefix,"End\r\n",-1);
  499.  
  500. #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt)     \
  501.         OleDbgPrintRefCnt(2,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  502.  
  503. #define OleDbgOutRect2(lpsz,lpRect)     \
  504.         OleDbgPrintRect(2,g_szDbgPrefix,lpsz,lpRect)
  505.  
  506. #define OleDbgOut3(lpsz)    \
  507.         OleDbgPrint(3,g_szDbgPrefix,lpsz,0)
  508.  
  509. #define OleDbgOutNoPrefix3(lpsz)    \
  510.         OleDbgPrint(3,"",lpsz,0)
  511.  
  512. #define OLEDBG_BEGIN3(lpsz)    \
  513.         OleDbgPrint(3,g_szDbgPrefix,lpsz,1);
  514.  
  515. #define OLEDBG_END3 \
  516.         OleDbgPrint(3,g_szDbgPrefix,"End\r\n",-1);
  517.  
  518. #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt)     \
  519.         OleDbgPrintRefCnt(3,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  520.  
  521. #define OleDbgOutRect3(lpsz,lpRect)     \
  522.         OleDbgPrintRect(3,g_szDbgPrefix,lpsz,lpRect)
  523.  
  524. #define OleDbgOut4(lpsz)    \
  525.         OleDbgPrint(4,g_szDbgPrefix,lpsz,0)
  526.  
  527. #define OleDbgOutNoPrefix4(lpsz)    \
  528.         OleDbgPrint(4,"",lpsz,0)
  529.  
  530. #define OLEDBG_BEGIN4(lpsz)    \
  531.         OleDbgPrint(4,g_szDbgPrefix,lpsz,1);
  532.  
  533. #define OLEDBG_END4 \
  534.         OleDbgPrint(4,g_szDbgPrefix,"End\r\n",-1);
  535.  
  536. #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt)     \
  537.         OleDbgPrintRefCnt(4,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  538.  
  539. #define OleDbgOutRect4(lpsz,lpRect)     \
  540.         OleDbgPrintRect(4,g_szDbgPrefix,lpsz,lpRect)
  541.  
  542. #else   //  !_DEBUG
  543.  
  544. #define OLEDBGDATA_MAIN(szPrefix)
  545. #define OLEDBGDATA
  546. #define OleDbgAssert(a)
  547. #define OleDbgAssertSz(a, b)
  548. #define OleDbgVerify(a)         (a)
  549. #define OleDbgVerifySz(a, b)    (a)
  550. #define OleDbgOutHResult(lpsz,hr)
  551. #define OleDbgOutScode(lpsz,sc)
  552. #define OLEDBG_BEGIN(lpsz)
  553. #define OLEDBG_END
  554. #define OleDbgOut(lpsz)
  555. #define OleDbgOut1(lpsz)
  556. #define OleDbgOut2(lpsz)
  557. #define OleDbgOut3(lpsz)
  558. #define OleDbgOut4(lpsz)
  559. #define OleDbgOutNoPrefix(lpsz)
  560. #define OleDbgOutNoPrefix1(lpsz)
  561. #define OleDbgOutNoPrefix2(lpsz)
  562. #define OleDbgOutNoPrefix3(lpsz)
  563. #define OleDbgOutNoPrefix4(lpsz)
  564. #define OLEDBG_BEGIN1(lpsz)
  565. #define OLEDBG_BEGIN2(lpsz)
  566. #define OLEDBG_BEGIN3(lpsz)
  567. #define OLEDBG_BEGIN4(lpsz)
  568. #define OLEDBG_END1
  569. #define OLEDBG_END2
  570. #define OLEDBG_END3
  571. #define OLEDBG_END4
  572. #define OleDbgOutRefCnt(lpsz,lpObj,refcnt)
  573. #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt)
  574. #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt)
  575. #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt)
  576. #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt)
  577. #define OleDbgOutRect(lpsz,lpRect)
  578. #define OleDbgOutRect1(lpsz,lpRect)
  579. #define OleDbgOutRect2(lpsz,lpRect)
  580. #define OleDbgOutRect3(lpsz,lpRect)
  581. #define OleDbgOutRect4(lpsz,lpRect)
  582.  
  583. #endif  //  _DEBUG
  584.  
  585.  
  586. /*************************************************************************
  587. ** Function prototypes
  588. *************************************************************************/
  589.  
  590.  
  591. //OLESTD.C
  592. STDAPI_(int) SetDCToAnisotropic(HDC hDC, LPRECT lprcPhysical, LPRECT lprcLogical, LPRECT lprcWindowOld, LPRECT lprcViewportOld);
  593. STDAPI_(int) SetDCToDrawInHimetricRect(HDC, LPRECT, LPRECT, LPRECT, LPRECT);
  594. STDAPI_(int) ResetOrigDC(HDC, int, LPRECT, LPRECT);
  595.  
  596. STDAPI_(int)        XformWidthInHimetricToPixels(HDC, int);
  597. STDAPI_(int)        XformWidthInPixelsToHimetric(HDC, int);
  598. STDAPI_(int)        XformHeightInHimetricToPixels(HDC, int);
  599. STDAPI_(int)        XformHeightInPixelsToHimetric(HDC, int);
  600.  
  601. STDAPI_(void) XformRectInPixelsToHimetric(HDC, LPRECT, LPRECT);
  602. STDAPI_(void) XformRectInHimetricToPixels(HDC, LPRECT, LPRECT);
  603. STDAPI_(void) XformSizeInPixelsToHimetric(HDC, LPSIZEL, LPSIZEL);
  604. STDAPI_(void) XformSizeInHimetricToPixels(HDC, LPSIZEL, LPSIZEL);
  605. STDAPI_(int) XformWidthInHimetricToPixels(HDC, int);
  606. STDAPI_(int) XformWidthInPixelsToHimetric(HDC, int);
  607. STDAPI_(int) XformHeightInHimetricToPixels(HDC, int);
  608. STDAPI_(int) XformHeightInPixelsToHimetric(HDC, int);
  609.  
  610. STDAPI_(void) ParseCmdLine(LPSTR, BOOL FAR *, LPSTR);
  611.  
  612. STDAPI_(BOOL) OleStdIsOleLink(LPUNKNOWN lpUnk);
  613. STDAPI_(LPUNKNOWN) OleStdQueryInterface(LPUNKNOWN lpUnk, REFIID riid);
  614. STDAPI_(LPSTORAGE) OleStdCreateRootStorage(LPSTR lpszStgName, DWORD grfMode);
  615. STDAPI_(LPSTORAGE) OleStdOpenRootStorage(LPSTR lpszStgName, DWORD grfMode);
  616. STDAPI_(LPSTORAGE) OleStdOpenOrCreateRootStorage(LPSTR lpszStgName, DWORD grfMode);
  617. STDAPI_(LPSTORAGE) OleStdCreateChildStorage(LPSTORAGE lpStg, LPSTR lpszStgName);
  618. STDAPI_(LPSTORAGE) OleStdOpenChildStorage(LPSTORAGE lpStg, LPSTR lpszStgName, DWORD grfMode);
  619. STDAPI_(BOOL) OleStdCommitStorage(LPSTORAGE lpStg);
  620. STDAPI OleStdDestroyAllElements(LPSTORAGE lpStg);
  621.  
  622. STDAPI_(LPSTORAGE) OleStdCreateStorageOnHGlobal(
  623.         HANDLE hGlobal,
  624.         BOOL fDeleteOnRelease,
  625.         DWORD dwgrfMode
  626. );
  627. STDAPI_(LPSTORAGE) OleStdCreateTempStorage(BOOL fUseMemory, DWORD grfMode);
  628. STDAPI OleStdDoConvert(LPSTORAGE lpStg, REFCLSID rClsidNew);
  629. STDAPI_(BOOL) OleStdGetTreatAsFmtUserType(
  630.         REFCLSID        rClsidApp,
  631.         LPSTORAGE       lpStg,
  632.         CLSID FAR*      lpclsid,
  633.         CLIPFORMAT FAR* lpcfFmt,
  634.         LPSTR FAR*      lplpszType
  635. );
  636. STDAPI OleStdDoTreatAsClass(LPSTR lpszUserType, REFCLSID rclsid, REFCLSID rclsidNew);
  637. STDAPI_(BOOL) OleStdSetupAdvises(LPOLEOBJECT lpOleObject, DWORD dwDrawAspect,
  638.                     LPSTR lpszContainerApp, LPSTR lpszContainerObj,
  639.                     LPADVISESINK lpAdviseSink, BOOL fCreate);
  640. STDAPI OleStdSwitchDisplayAspect(
  641.         LPOLEOBJECT             lpOleObj,
  642.         LPDWORD                 lpdwCurAspect,
  643.         DWORD                   dwNewAspect,
  644.         HGLOBAL                 hMetaPict,
  645.         BOOL                    fDeleteOldAspect,
  646.         BOOL                    fSetupViewAdvise,
  647.         LPADVISESINK            lpAdviseSink,
  648.         BOOL FAR*               lpfMustUpdate
  649. );
  650. STDAPI OleStdSetIconInCache(LPOLEOBJECT lpOleObj, HGLOBAL hMetaPict);
  651. STDAPI_(HGLOBAL) OleStdGetData(
  652.         LPDATAOBJECT        lpDataObj,
  653.         CLIPFORMAT          cfFormat,
  654.         DVTARGETDEVICE FAR* lpTargetDevice,
  655.         DWORD               dwAspect,
  656.         LPSTGMEDIUM         lpMedium
  657. );
  658. STDAPI_(void) OleStdMarkPasteEntryList(
  659.         LPDATAOBJECT        lpSrcDataObj,
  660.         LPOLEUIPASTEENTRY   lpPriorityList,
  661.         int                 cEntries
  662. );
  663. STDAPI_(int) OleStdGetPriorityClipboardFormat(
  664.         LPDATAOBJECT        lpSrcDataObj,
  665.         LPOLEUIPASTEENTRY   lpPriorityList,
  666.         int                 cEntries
  667. );
  668. STDAPI_(BOOL) OleStdIsDuplicateFormat(
  669.         LPFORMATETC         lpFmtEtc,
  670.         LPFORMATETC         arrFmtEtc,
  671.         int                 nFmtEtc
  672. );
  673. STDAPI_(void) OleStdRegisterAsRunning(LPUNKNOWN lpUnk, LPMONIKER lpmkFull, DWORD FAR* lpdwRegister);
  674. STDAPI_(void) OleStdRevokeAsRunning(DWORD FAR* lpdwRegister);
  675. STDAPI_(void) OleStdNoteFileChangeTime(LPSTR lpszFileName, DWORD dwRegister);
  676. STDAPI_(void) OleStdNoteObjectChangeTime(DWORD dwRegister);
  677. STDAPI OleStdGetOleObjectData(
  678.         LPPERSISTSTORAGE    lpPStg,
  679.         LPFORMATETC         lpformatetc,
  680.         LPSTGMEDIUM         lpMedium,
  681.         BOOL                fUseMemory
  682. );
  683. STDAPI OleStdGetLinkSourceData(
  684.         LPMONIKER           lpmk,
  685.         LPCLSID             lpClsID,
  686.         LPFORMATETC         lpformatetc,
  687.         LPSTGMEDIUM         lpMedium
  688. );
  689. STDAPI_(HGLOBAL) OleStdGetObjectDescriptorData(
  690.         CLSID               clsid,
  691.         DWORD               dwAspect,
  692.         SIZEL               sizel,
  693.         POINTL              pointl,
  694.         DWORD               dwStatus,
  695.         LPSTR               lpszFullUserTypeName,
  696.         LPSTR               lpszSrcOfCopy
  697. );
  698. STDAPI_(HGLOBAL) OleStdGetObjectDescriptorDataFromOleObject(
  699.         LPOLEOBJECT         lpOleObj,
  700.         LPSTR               lpszSrcOfCopy,
  701.         DWORD               dwAspect,
  702.         POINTL              pointl,
  703.         LPSIZEL             lpSizelHim
  704. );
  705. STDAPI_(HGLOBAL) OleStdFillObjectDescriptorFromData(
  706.         LPDATAOBJECT       lpDataObject,
  707.         LPSTGMEDIUM        lpmedium,
  708.         CLIPFORMAT FAR*    lpcfFmt
  709. );
  710. STDAPI_(HANDLE) OleStdGetMetafilePictFromOleObject(
  711.         LPOLEOBJECT         lpOleObj,
  712.         DWORD               dwDrawAspect,
  713.         LPSIZEL             lpSizelHim,
  714.         DVTARGETDEVICE FAR* ptd
  715. );
  716.  
  717. STDAPI_(void) OleStdCreateTempFileMoniker(LPSTR lpszPrefixString, UINT FAR* lpuUnique, LPSTR lpszName, LPMONIKER FAR* lplpmk);
  718. STDAPI_(LPMONIKER) OleStdGetFirstMoniker(LPMONIKER lpmk);
  719. STDAPI_(ULONG) OleStdGetLenFilePrefixOfMoniker(LPMONIKER lpmk);
  720. STDAPI OleStdMkParseDisplayName(
  721.         REFCLSID        rClsid,
  722.         LPBC            lpbc,
  723.         LPSTR           lpszUserName,
  724.         ULONG FAR*      lpchEaten,
  725.         LPMONIKER FAR*  lplpmk
  726. );
  727. STDAPI_(LPVOID) OleStdMalloc(ULONG ulSize);
  728. STDAPI_(LPVOID) OleStdRealloc(LPVOID pmem, ULONG ulSize);
  729. STDAPI_(void) OleStdFree(LPVOID pmem);
  730. STDAPI_(ULONG) OleStdGetSize(LPVOID pmem);
  731. STDAPI_(void) OleStdFreeString(LPSTR lpsz, LPMALLOC lpMalloc);
  732. STDAPI_(LPSTR) OleStdCopyString(LPSTR lpszSrc, LPMALLOC lpMalloc);
  733. STDAPI_(ULONG) OleStdGetItemToken(LPSTR lpszSrc, LPSTR lpszDst,int nMaxChars);
  734.  
  735. STDAPI_(UINT)     OleStdIconLabelTextOut(HDC        hDC,
  736.                                          HFONT      hFont,
  737.                                          int        nXStart,
  738.                                          int        nYStart,
  739.                                          UINT       fuOptions,
  740.                                          RECT FAR * lpRect,
  741.                                          LPSTR      lpszString,
  742.                                          UINT       cchString,
  743.                                          int FAR *  lpDX);
  744.  
  745. // registration database query functions
  746. STDAPI_(UINT)     OleStdGetAuxUserType(REFCLSID rclsid,
  747.                                       WORD   wAuxUserType,
  748.                                       LPSTR  lpszAuxUserType,
  749.                                       int    cch,
  750.                                       HKEY   hKey);
  751.  
  752. STDAPI_(UINT)     OleStdGetUserTypeOfClass(REFCLSID rclsid,
  753.                                            LPSTR lpszUserType,
  754.                                            UINT cch,
  755.                                            HKEY hKey);
  756.  
  757. STDAPI_(BOOL) OleStdGetMiscStatusOfClass(REFCLSID, HKEY, DWORD FAR *);
  758. STDAPI_(CLIPFORMAT) OleStdGetDefaultFileFormatOfClass(
  759.         REFCLSID        rclsid,
  760.         HKEY            hKey
  761. );
  762.  
  763. STDAPI_(void) OleStdInitVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl);
  764. STDMETHODIMP OleStdNullMethod(LPUNKNOWN lpThis);
  765. STDAPI_(BOOL) OleStdCheckVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl, LPSTR lpszIface);
  766. STDAPI_(ULONG) OleStdVerifyRelease(LPUNKNOWN lpUnk, LPSTR lpszMsg);
  767. STDAPI_(ULONG) OleStdRelease(LPUNKNOWN lpUnk);
  768.  
  769. STDAPI_(HDC) OleStdCreateDC(DVTARGETDEVICE FAR* ptd);
  770. STDAPI_(HDC) OleStdCreateIC(DVTARGETDEVICE FAR* ptd);
  771. STDAPI_(DVTARGETDEVICE FAR*) OleStdCreateTargetDevice(LPPRINTDLG lpPrintDlg);
  772. STDAPI_(BOOL) OleStdDeleteTargetDevice(DVTARGETDEVICE FAR* ptd);
  773. STDAPI_(DVTARGETDEVICE FAR*) OleStdCopyTargetDevice(DVTARGETDEVICE FAR* ptdSrc);
  774. STDAPI_(BOOL) OleStdCopyFormatEtc(LPFORMATETC petcDest, LPFORMATETC petcSrc);
  775. STDAPI_(int) OleStdCompareFormatEtc(FORMATETC FAR* pFetcLeft, FORMATETC FAR* pFetcRight);
  776. STDAPI_(BOOL) OleStdCompareTargetDevice
  777.     (DVTARGETDEVICE FAR* ptdLeft, DVTARGETDEVICE FAR* ptdRight);
  778.  
  779.  
  780. STDAPI_(void) OleDbgPrint(
  781.         int     nDbgLvl,
  782.         LPSTR   lpszPrefix,
  783.         LPSTR   lpszMsg,
  784.         int     nIndent
  785. );
  786. STDAPI_(void) OleDbgPrintAlways(LPSTR lpszPrefix, LPSTR lpszMsg, int nIndent);
  787. STDAPI_(void) OleDbgSetDbgLevel(int nDbgLvl);
  788. STDAPI_(int) OleDbgGetDbgLevel( void );
  789. STDAPI_(void) OleDbgIndent(int n);
  790. STDAPI_(void) OleDbgPrintRefCnt(
  791.         int         nDbgLvl,
  792.         LPSTR       lpszPrefix,
  793.         LPSTR       lpszMsg,
  794.         LPVOID      lpObj,
  795.         ULONG       refcnt
  796. );
  797. STDAPI_(void) OleDbgPrintRefCntAlways(
  798.         LPSTR       lpszPrefix,
  799.         LPSTR       lpszMsg,
  800.         LPVOID      lpObj,
  801.         ULONG       refcnt
  802. );
  803. STDAPI_(void) OleDbgPrintRect(
  804.         int         nDbgLvl,
  805.         LPSTR       lpszPrefix,
  806.         LPSTR       lpszMsg,
  807.         LPRECT      lpRect
  808. );
  809. STDAPI_(void) OleDbgPrintRectAlways(
  810.         LPSTR       lpszPrefix,
  811.         LPSTR       lpszMsg,
  812.         LPRECT      lpRect
  813. );
  814. STDAPI_(void) OleDbgPrintScodeAlways(LPSTR lpszPrefix, LPSTR lpszMsg, SCODE sc);
  815.  
  816. // debug implementation of the IMalloc interface.
  817. STDAPI OleStdCreateDbAlloc(ULONG reserved, IMalloc FAR* FAR* ppmalloc);
  818.  
  819.  
  820. STDAPI_(LPENUMFORMATETC)
  821.   OleStdEnumFmtEtc_Create(ULONG nCount, LPFORMATETC lpEtc);
  822.  
  823. STDAPI_(LPENUMSTATDATA)
  824.   OleStdEnumStatData_Create(ULONG nCount, LPSTATDATA lpStat);
  825.  
  826. STDAPI_(BOOL)
  827.   OleStdCopyStatData(LPSTATDATA pDest, LPSTATDATA pSrc);
  828.  
  829. STDAPI_(HPALETTE)
  830.   OleStdCreateStandardPalette(void);
  831.  
  832. #if defined( OBSOLETE )
  833.  
  834. /*************************************************************************
  835. ** The following API's have been converted into macros:
  836. **          OleStdQueryOleObjectData
  837. **          OleStdQueryLinkSourceData
  838. **          OleStdQueryObjectDescriptorData
  839. **          OleStdQueryFormatMedium
  840. **          OleStdCopyMetafilePict
  841. **          AreRectsEqual
  842. **          OleStdGetDropEffect
  843. **
  844. **    These macros are defined above
  845. *************************************************************************/
  846. STDAPI_(BOOL) AreRectsEqual(LPRECT lprc1, LPRECT lprc2);
  847. STDAPI_(BOOL) OleStdCopyMetafilePict(HANDLE hpictin, HANDLE FAR* phpictout);
  848. STDAPI OleStdQueryOleObjectData(LPFORMATETC lpformatetc);
  849. STDAPI OleStdQueryLinkSourceData(LPFORMATETC lpformatetc);
  850. STDAPI OleStdQueryObjectDescriptorData(LPFORMATETC lpformatetc);
  851. STDAPI OleStdQueryFormatMedium(LPFORMATETC lpformatetc, TYMED tymed);
  852. STDAPI_(DWORD) OleStdGetDropEffect ( DWORD grfKeyState );
  853. #endif  // OBSOLETE
  854.  
  855. #endif  /* RC_INVOKED */
  856.  
  857. #ifdef BJAPAN
  858. unsigned int NthCType( char *pC, int pos );
  859. #endif
  860.  
  861. #endif // _OLESTD_H_
  862.